import * as proxy from '../proxy';
import ServiceBase from '../base';
import {CollectionPageProxy, CollectionProxy} from '../proxies/file-proxy';

const GET_FILES = '/accounts';

class CollectionService extends ServiceBase {
    // POST /accounts/{accountId}/projects/{projectId}/subscriptions 订阅
    postCollection = (data) => {
        let promise = super.post({
            url: `${GET_FILES}/${data.accountId}/projects/${data.projectId}/collections`,
            data: data.data,
        });
        return proxy.httpResultProxy(promise, CollectionProxy);
    };
    // GET /accounts/{accountId}/projects/{projectId}/subscriptions 查询订阅信息
    getCollections = (data) => {
        let promise = super.get({
            url: `${GET_FILES}/${data.accountId}/projects/${data.projectId}/collections`,
        });
        return proxy.httpResultProxy(promise, CollectionPageProxy);
    };
    // GET /accounts/{accountId}/projects/{projectId}/subscriptions/search  查询订阅信息
    getCollectionSearch = (data) => {
        let promise = super.get({
            url: `${GET_FILES}/${data.accountId}/projects/${data.projectId}/collections/search`,
            params: data.query,
        });
        return proxy.httpResultProxy(promise, CollectionPageProxy);
    };
    // DELETE /accounts/{accountId}/projects/{projectId}/subscriptions delete
    deleteCollection = (data) => {
        let promise = super.delete({
            url: `${GET_FILES}/${data.accountId}/projects/${data.projectId}/collections`,
            data: data.data,
        });
        return proxy.httpResultProxy(promise);
    };
}
export {CollectionService};
